package com.fly.main;

import org.apache.commons.lang3.RandomUtils;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.context.support.FileSystemXmlApplicationContext;
import org.springframework.context.support.GenericXmlApplicationContext;

import lombok.extern.slf4j.Slf4j;

/**
 * 
 * Main
 * 
 * @author 00fly
 * @version [版本号, 2018-11-06]
 * @see [相关类/方法]
 * @since [产品/模块版本]
 */
@Slf4j
public class MainRun
{
    /**
     * Main
     * 
     * @param args
     * @see [类、类#方法、类#成员]
     */
    public static void main(String[] args)
    {
        ApplicationContext applicationContext;
        int input = RandomUtils.nextInt() % 5;
        log.info("###### input: {}", input);
        switch (input)
        {
            case 0:
                applicationContext = new ClassPathXmlApplicationContext("applicationContext.xml");
                break;
            case 1:
                applicationContext = new FileSystemXmlApplicationContext("classpath:applicationContext.xml");
                break;
            default:
                applicationContext = new GenericXmlApplicationContext("classpath:applicationContext.xml");
        }
        
        log.info("★★★★★★★★ ApplicationContext = {}", applicationContext);
        int i = 1;
        for (String beanName : applicationContext.getBeanDefinitionNames())
        {
            log.info("{}.\t{}", i, beanName);
            i++;
        }
    }
}
